﻿using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SSIS.Test.Dts;
using SSIS.Test.Metadata;

namespace SSIS.Test.Template.Demo.UnitTests
{
    [UnitTest("DEMO", "CopyCustomers.dtsx", ExecutableName = @"\[CopyCustomers]\[FST Copy Source File]")]
    class CopyCustomersFileCopy : BaseUnitTest
    {
        protected override void Setup(SetupContext context)
        {
            DtsVariable custSrc = context.Package.GetVariableForPath(@"\[CopyCustomers].[SourcePath]");
            custSrc.SetValue(Constants.CustomersFileSource);

            DtsVariable custDest = context.Package.GetVariable(@"DestinationPath");
            custDest.SetValue(Constants.CustomersFileDestination);
        }

        protected override void Verify(VerificationContext context)
        {
            bool exists =
               File.Exists(Constants.CustomersFileDestination);

            Assert.AreEqual(true, context.ActiveExecutable.IsExecutionSuccess);
            Assert.AreEqual(true, exists);
        }

        protected override void Teardown(TeardownContext context)
        {
            File.Delete(Constants.CustomersFileDestination);
        }
    }
}
